package com.workflow.engine.eb.config;

import com.workflow.engine.core.flow.FlowBuilder;
import com.workflow.engine.core.flow.IStep;
import com.workflow.engine.core.flow.impl.Flow;
import com.workflow.engine.core.utils.FlowBuilderUtil;
import com.workflow.engine.core.utils.ResourcesUtil;
import com.workflow.engine.eb.steps.jd.data.JDGetCouponCount;
import com.workflow.engine.eb.steps.jd.data.JDGetEasyBuyList;
import com.workflow.engine.eb.steps.jd.login.JDGetLab;
import com.workflow.engine.eb.steps.jd.login.JDGetLoginParams;
import com.workflow.engine.eb.steps.jd.login.JDGetUserVerifyRight;
import com.workflow.engine.eb.steps.jd.login.JDJumpToIndex;
import com.workflow.engine.eb.steps.jd.login.JDLoginIndex;
import com.workflow.engine.eb.steps.jd.login.JDLoginService;
import com.workflow.engine.eb.steps.jd.login.JDLoginServiceAspx;
import com.workflow.engine.eb.steps.jd.login.JDSSORedirect;
import com.workflow.engine.eb.steps.jd.login.JDShowAuthCodeVerify;
import com.workflow.engine.eb.steps.jd.login.JDVerifyAuthCode;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

/**
 * Created by houjinxin on 2017/2/23.
 */
public class FlowConfig {

    private static String flowFilePath = ResourcesUtil.getFlowFilePathByName("FLOW_FILE_NAME");
    private static Map<String, Class<? extends IStep>> nameStepClazzMappings = new HashMap<String, Class<? extends IStep>>() {{
        put("从浏览器获取登录相关参数", JDGetLoginParams.class);
        put("检查是否需要输入验证码",   JDShowAuthCodeVerify.class);
        put("发送登录请求",            JDLoginService.class);
        put("JDLoginIndex",          JDLoginIndex.class);
        put("识别验证码",             JDVerifyAuthCode.class);
        put("跳转到首页",             JDJumpToIndex.class);
        put("SSO单点登录",            JDSSORedirect.class);
        put("获取LAB",                JDGetLab.class);
        put("校验是否登录成功",        JDLoginServiceAspx.class);
        put("获取小白信用额度",        JDGetUserVerifyRight.class);
        put("获取优惠券个数",          JDGetCouponCount.class);
        put("获取收货地址",                      JDGetEasyBuyList.class);
        put("失败",                  JDGetUserVerifyRight.class);
    }};
    private static  LinkedList<Object> flowStepOrderConfig = FlowBuilderUtil.extractSteps(flowFilePath);
    public static Flow _FLOW = new FlowBuilder(nameStepClazzMappings, flowStepOrderConfig).build();


}
